# Contributor: Clayton Craft <clayton@craftyguy.net>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=goimapnotify
pkgver=2.3.7
pkgrel=4
pkgdesc="execute scripts on IMAP mailbox changes using IDLE, golang version"
url="https://gitlab.com/shackra/goimapnotify"
arch="all"
license="GPL-3.0-or-later"
makedepends="go"
options="net"
source="https://gitlab.com/shackra/goimapnotify/-/archive/$pkgver/goimapnotify-$pkgver.tar.gz"

build() {
	export CGO_CPPFLAGS="$CPPFLAGS"
	export CGO_CFLAGS="$CFLAGS"
	export CGO_CXXFLAGS="$CXXFLAGS"
	export CGO_LDFLAGS="$LDFLAGS"
	export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"

	# Fix build on riscv64
	go mod edit -replace \
		golang.org/x/sys=golang.org/x/sys@v0.0.0-20210630005230-0f9fa26af87c
	go mod download golang.org/x/sys

	go build -ldflags "-linkmode=external -extldflags=$LDFLAGS"
}

check() {
	go test ./...
}

package() {
	install -Dm755 goimapnotify "$pkgdir"/usr/bin/goimapnotify
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE
}

sha512sums="
7551ec498c3414448b21bf4202a69bbab8815dd9423638b3adbf31fb2857a008fb6f1ac78e41ce695550931dfe4ba9c49050f3bfcab2d646f37547a7efcdaff7  goimapnotify-2.3.7.tar.gz
"
